#ifndef SubscriberSlot_H
#define SubscriberSlot_H

#include "FunctorPointerSlot.h"
#include "MemberFunctionSlot.h"

class SubscriberSlot
{
public:
    SubscriberSlot();
    ~SubscriberSlot();
    bool operator()(void* dispatcher,const EventArgs& args) const
    {
        return (*d_functor_impl)(dispatcher,args);
    }
    bool connected() const
    {
        return d_functor_impl != 0;
    }
    void cleanup();

    template<typename T>
    SubscriberSlot(bool (T::*function)(const EventArgs&), T* obj) :
        d_functor_impl(new MemberFunctionSlot<T>(function, obj))
    {}
    template<typename T>
    SubscriberSlot(T* functor) :
        d_functor_impl(new FunctorPointerSlot<T>(functor))
    {}

private:
    SlotFunctorBase* d_functor_impl;
};
#endif
